package com.pai4j.common.enums.community;

import com.chat4j.common.exception.ParamException;
import lombok.Getter;
import org.springframework.util.Assert;

/**
 * @Author: 程序员七七
 * @Date: 23.11.21 1:28 上午
 */
@Getter
public enum ReviewStatusEnum {

    WAITE_REVIEW(0, "待审核"),

    REFUSE_SYSTEM(-1, "未通过、机审"),

    REFUSE_USER(-2, "未通过、人审"),

    PASS_SCORE_1(1, "通过、一般"),

    PASS_SCORE_2(2, "通过、优质");

    private Integer statusCode;

    private String statusDesc;

    ReviewStatusEnum(Integer statusCode, String statusDesc) {
        this.statusCode = statusCode;
        this.statusDesc = statusDesc;
    }

    public static void validateStatus(Integer statusCode) {
        Assert.isTrue(statusCode != null, "审核状态有误");
        for (ReviewStatusEnum reviewStatusEnum : ReviewStatusEnum.values()) {
            if (reviewStatusEnum.statusCode.equals(statusCode)) {
                return;
            }
        }
        throw new ParamException("审核状态有误");
    }

    /***
     * 是否审核通过
     * @param statusCode
     * @return
     */
    public static boolean isPass(Integer statusCode) {
        return PASS_SCORE_1.statusCode.equals(statusCode) || PASS_SCORE_2.statusCode.equals(statusCode);
    }

    public static String getViewStatusDesc(Integer statusCode) {
        for (ReviewStatusEnum reviewStatusEnum : ReviewStatusEnum.values()) {
            if (reviewStatusEnum.statusCode.equals(statusCode)) {
                return reviewStatusEnum.statusDesc;
            }
        }
        return "未识别到";
    }
}
